package com.spic.business.train.trainInfoCourseware.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.common.security.annotation.PreAuthorize;
import com.spic.business.train.trainInfoCourseware.domain.TrainInfoCourseware;
import com.spic.business.train.trainInfoCourseware.service.ITrainInfoCoursewareService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.page.TableDataInfo;

/**
 * 培训信息_培训课件中间Controller
 * 
 * @author spic
 * @date 2021-10-21
 */
@RestController
@RequestMapping("/train/trainInfoCourseware")
public class TrainInfoCoursewareController extends BaseController
{
    @Autowired
    private ITrainInfoCoursewareService trainInfoCoursewareService;

    /**
     * 查询培训信息_培训课件中间列表
     */
    @PreAuthorize(hasPermi = "business/train:trainInfoCourseware:list")
    @GetMapping("/list")
    public TableDataInfo list(TrainInfoCourseware trainInfoCourseware)
    {
        startPage();
        List<TrainInfoCourseware> list = trainInfoCoursewareService.selectTrainInfoCoursewareList(trainInfoCourseware);
        return getDataTable(list);
    }

    /**
     * 导出培训信息_培训课件中间列表
     */
    @PreAuthorize(hasPermi = "business/train:trainInfoCourseware:export")
    @Log(title = "培训信息_培训课件中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrainInfoCourseware trainInfoCourseware) throws IOException
    {
        List<TrainInfoCourseware> list = trainInfoCoursewareService.selectTrainInfoCoursewareList(trainInfoCourseware);
        ExcelUtil<TrainInfoCourseware> util = new ExcelUtil<TrainInfoCourseware>(TrainInfoCourseware.class);
        util.exportExcel(response, list, "培训信息_培训课件中间数据");
    }

    /**
     * 获取培训信息_培训课件中间详细信息
     */
    @PreAuthorize(hasPermi = "business/train:trainInfoCourseware:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(trainInfoCoursewareService.selectTrainInfoCoursewareById(id));
    }
    /**
     * 根据培训信息id获取
     */
    //@PreAuthorize(hasPermi = "business/train:trainInfoCourseware:query")
    @GetMapping(value = "/{trainInfoId}")
    public TableDataInfo selectBytrainInfoId(@PathVariable("trainInfoId") String trainInfoId)
    {
        List<TrainInfoCourseware> list = trainInfoCoursewareService.selectBytrainInfoId(trainInfoId);
        return getDataTable(list);
    }
    /**
     * 新增培训信息_培训课件中间
     */
    @PreAuthorize(hasPermi = "business/train:trainInfoCourseware:add")
    @Log(title = "培训信息_培训课件中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainInfoCourseware trainInfoCourseware)
    {
        return toAjax(trainInfoCoursewareService.insertTrainInfoCourseware(trainInfoCourseware));
    }

    /**
     * 修改培训信息_培训课件中间
     */
    @PreAuthorize(hasPermi = "business/train:trainInfoCourseware:edit")
    @Log(title = "培训信息_培训课件中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrainInfoCourseware trainInfoCourseware)
    {
        return toAjax(trainInfoCoursewareService.updateTrainInfoCourseware(trainInfoCourseware));
    }

    /**
     * 删除培训信息_培训课件中间
     */
    @PreAuthorize(hasPermi = "business/train:trainInfoCourseware:remove")
    @Log(title = "培训信息_培训课件中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(trainInfoCoursewareService.deleteTrainInfoCoursewareByIds(ids));
    }
}
